package com.ruoyi.foreignlanguage.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.foreignlanguage.domain.ExamForeignLanguage;
import com.ruoyi.foreignlanguage.service.IExamForeignLanguageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "基础管理-外语信息")
@RestController
@RequestMapping("/foreignlanguage")
public class ExamForeignLanguageController {

    @Autowired
    private IExamForeignLanguageService foreignLanguageService;

    /**
     * 查询外语列表
     */
                @ApiOperation("外语管理 - 分页查询列表")
    @GetMapping("/list")
    public AjaxResult list() {
        List<ExamForeignLanguage> list = foreignLanguageService.selectForeignLanguageList();
        return AjaxResult.success(list);
    }

    /**
     * 根据ID获取外语详情
     */
                @ApiOperation("外语管理 - 根据ID获取详细信息")
    @GetMapping("/info")
    public AjaxResult getInfo(@RequestParam Long id) {
        return AjaxResult.success(foreignLanguageService.selectForeignLanguageById(id));
    }

    /**
     * 新增外语
     */
                @ApiOperation("外语管理 - 新增数据")
    @PostMapping
    public AjaxResult add(@RequestBody ExamForeignLanguage foreignLanguage) {
        return AjaxResult.success(foreignLanguageService.insertForeignLanguage(foreignLanguage));
    }

    /**
     * 修改外语
     */
                @ApiOperation("外语管理 - 修改数据")
    @PutMapping
    public AjaxResult edit(@RequestBody ExamForeignLanguage foreignLanguage) {
        return AjaxResult.success(foreignLanguageService.updateForeignLanguage(foreignLanguage));
    }

    /**
     * 删除外语
     */
                @ApiOperation("外语管理 - 删除数据")
    @DeleteMapping
    public AjaxResult remove(@RequestParam Long id) {
        return AjaxResult.success(foreignLanguageService.deleteForeignLanguageById(id));
    }
}
